﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using System;
using System.Collections.Generic;
using InterLinq.Base;
using Sebarf.Services.Interfaces;

#endregion

namespace Sebastof.Client.Services.Impl {
	/// <summary>
	/// This service provides a store for object data.
	/// Needed for backing up original data for later comparison to check if changes are existent.
	/// </summary>
	public class ChangeTrackingCacheService : Service, IChangeTrackingCacheService {
		private readonly Dictionary<Type, Dictionary<object, Dictionary<string, object>>> EntityStore =
			new Dictionary<Type, Dictionary<object, Dictionary<string, object>>>();

		#region IChangeTrackingCacheService Members

		public Dictionary<Type, Dictionary<object, Dictionary<string, object>>> GetStoreOfNonSebastofObjectsOriginalData() {
			return EntityStore;
		}

		#endregion

		protected override ServiceStatistics OnCollectStatisticData(ServiceStatistics statisticData) {
			int i = 0;
			foreach (Type k in EntityStore.Keys) {
				i += EntityStore[k].Count;
			}
			statisticData.AddEntry("EntryCount", (double)i);
			return statisticData;
		}
	}
}